# @shuaige : 陈世玉
# @name :toCsv.py
# @time :2024/12/7 22:31
import requests
import json
url="https://www.shanghairanking.cn/_nuxt/static/1733299889/rankings/bcur/2024/payload.js"
headers={
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36'
}
res=requests.get(url,headers=headers)
text=res.text
index=text.find('univData')
lastindex=text.find(',indList')
fanaldata="{"+text[index:lastindex]
data=fanaldata.json()
#将fanaldata转化为json数据
# fanaldata=json.loads(fanaldata)
# fanaldata=json.loads(fanaldata)
print(type(fanaldata))
# with open('data.json','w',encoding='utf-8') as f:
#     f.write(fanaldata)

